# import io
# from seal import EncryptionParameters, SEALContext, CoeffModulus, PlainModulus, scheme_type
# from encryption import FileEncryptor
# from fhe_decryption import FileDecryptor
# from key_management import KeyManager
# from oss_ops import OssHandler
# from circuits import BooleanCircuit

# def main():
#     try:
#         parms = EncryptionParameters(scheme_type.bgv)
#         parms.set_poly_modulus_degree(8192)
#         parms.set_coeff_modulus(CoeffModulus.BFVDefault(8192))  # 使用BFVDefault生成兼容链
#         parms.set_plain_modulus(PlainModulus.Batching(8192, 20))
#         context = SEALContext(parms)

#         oss_handler = OssHandler('LTAI5tKWddkbjVhbzavB5Cgr', '4pPqJK9igFh3pcBJZYoJZdgXWnLGlI',
#                                 'medicalinformation', 'http://oss-cn-beijing.aliyuncs.com')
#         key_manager = KeyManager(oss_handler)

#         encryptor = FileEncryptor(context, key_manager, oss_handler)

#         # # 假设你有一个文件路径
#         file_path = 'D:/code/project/smart-oss/BGV/1.jpg'
#         output_file_path = 'D:/code/project/smart-oss/BGV/encroy.bin'

#         # # 打开文件，获取文件对象
#         with open(file_path, 'rb') as file:
#             file_obj = io.BytesIO(file.read())  # 读取文件并将其转换为 BytesIO 对象

#         # 设定文件名
#         filename = '1.jpg'  # 文件的名字，用于在 OSS 中创建目录


#         encryptor.encrypt_file(file_obj, filename, BooleanCircuit())

#         # decryptor = FileDecryptor(context, key_manager, oss_handler)
#         # decryptor.decrypt_file('1/', 'D:/code/project/smart-oss/BGV/decrypted.jpg')

#     except Exception as e:
#         print(f"Main error: {e}")

# if __name__ == '__main__':
#     main()